<template>
    <el-aside :width=" isCollapse? '64px':'200px'">
        <!--侧边栏展开折叠开关  -->
        <div class="toggle-button" @click="toggleCollapse">|||</div>
        <el-menu :default-active="this.$route.path" class="el-menu-vertical-demo" menu-trigger="click" background-color="#333744" text-color="#fff" active-text-color="#409EFF" router :collapse="isCollapse" :collapse-transition="false" :unique-opened="true" v-if="identity === 'super'">
            <el-menu-item index="/index">
                <i class="el-icon-s-home"></i>
                <span slot="title">首页</span>
            </el-menu-item>
            <el-menu-item index="/banner/index">
                <i class="el-icon-s-finance"></i>
                <span slot="title">轮播管理</span>
            </el-menu-item>
            <el-menu-item index="/con-nav/index">
                <i class="el-icon-s-order"></i>
                <span slot="title">模块导航</span>
            </el-menu-item>
            <el-menu-item index="/nav/index">
                <i class="el-icon-s-finance"></i>
                <span slot="title">单页导航</span>
            </el-menu-item>
            <el-menu-item index="/module/index">
                <i class="el-icon-s-help"></i>
                <span slot="title">网页内容</span>
            </el-menu-item>
            <el-menu-item index="/config-set/index">
                <i class="el-icon-s-tools"></i>
                <span slot="title">配置设置</span>
            </el-menu-item>
        </el-menu>
    </el-aside>
</template>

<script>
export default {
    data() {
        return {
            identity: "",
            // 是否折叠
            isCollapse: false,
        };
    },
    methods: {
        // 点击菜单按钮 控制展开与关闭
        toggleCollapse() {
            this.isCollapse = !this.isCollapse;
        },
        //防止logo页层级被遮挡，因为popper层级会叠加
        popoverHandle() {
            document.querySelector(".popper").style.zIndex = 1000;
        },
        setStatus(meta) {
            if (meta.user === "agent") {
                this.identity = "agent";
            } else if (meta.user === "master") {
                this.identity = "master";
            } else {
                this.identity = "super";
            }
            if (meta.index !== undefined) {
                this.activeIndex = meta.index;
            }
        },

    },
    watch: {
        $route(to, from) {
            this.setStatus(to.meta);
        },
    },
    created(e) {
        let a = { index: 1, user: "super" };
        this.setStatus(a);
    },
};
</script>

<style scoped>
.toggle-button {
    background-color: #4a5064;
    font-size: 10px;
    line-height: 24px;
    color: #ffffff;
    text-align: center;
    letter-spacing: 0.2em;
    cursor: pointer;
}
</style>
